package sc.writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.Writable;

/**
 * Contains the price data at the closure of the market for a stock. It includes
 * the prices at closure, the day highs and lows and the volume.
 * 
 * @author Quentin Rossé et Cédric Rais
 *
 */
public class PriceData implements Writable{
	
	/**
	 * prices of the stock when the market closed
	 */
	private WritableArrayListFloat closePrices;
	
	/**
	 * lowest price of the day for the stock
	 */
	private WritableArrayListFloat dayLowPrices;
	
	/**
	 * highest price of the day for the stock
	 */
	private WritableArrayListFloat dayHighPrices;
	
	
	/**
	 * 
	 */
	private WritableArrayListInteger volume;
	
	public PriceData(){
		closePrices = new WritableArrayListFloat();
		dayLowPrices = new WritableArrayListFloat();
		dayHighPrices = new WritableArrayListFloat();
		volume = new WritableArrayListInteger();
	}
	
	public PriceData(WritableArrayListFloat closePrices,
			         WritableArrayListFloat dayLowPrices,
			         WritableArrayListFloat dayHighPrices,
			         WritableArrayListInteger volume){
		this.closePrices = closePrices;
		this.dayLowPrices = dayLowPrices;
		this.dayHighPrices = dayHighPrices;
		this.volume = volume;
	}
	
	
	public WritableArrayListFloat getClosePrices() {
		return closePrices;
	}

	public void setClosePrices(WritableArrayListFloat closePrices) {
		this.closePrices = closePrices;
	}

	public WritableArrayListFloat getDayLowPrices() {
		return dayLowPrices;
	}

	public void setDayLowPrices(WritableArrayListFloat dayLowPrices) {
		this.dayLowPrices = dayLowPrices;
	}

	public WritableArrayListFloat getDayHighPrices() {
		return dayHighPrices;
	}

	public void setDayHighPrices(WritableArrayListFloat dayHighPrices) {
		this.dayHighPrices = dayHighPrices;
	}
	
	public WritableArrayListInteger getVolume(){
		return volume;
	}
	
	public void setVolume(WritableArrayListInteger volume){
		this.volume = volume;
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		closePrices.readFields(in);
		dayLowPrices.readFields(in);
		dayHighPrices.readFields(in);
		volume.readFields(in);
	}

	@Override
	public void write(DataOutput out) throws IOException {
		closePrices.write(out);
		dayLowPrices.write(out);
		dayHighPrices.write(out);
		volume.write(out);
	}

}
